package com.woniuxy.lab.woniu_lab.commons;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("Result响应对象")
public class Result<T> {
    @ApiModelProperty(value = "响应状态码", example = "200")
    Integer code;
    @ApiModelProperty(value = "响应的内容", example = "SUCCESS")
    String message;
    @ApiModelProperty("响应的数据")
    T data;

    // 静态方法
    public static <T> Result<T> success(Integer code, String message, T data){
        return new Result<>(code, message, data);
    }

    public static Result<Object> fail(Integer code, String message){
        return new Result<>(code, message, null);
    }

}
